home *** CD-ROM | disk | FTP | other *** search
/ PC Advisor 2007 June / PC Advisor 2007 June.iso / FULL / OPENOFFICE / openoffice.exe / openofficeorg3.cab / sofftodocbookheadings.xsl < prev    next >
Extensible Markup Language  |  2006-11-04  |  29KB  |  871 lines

  1. <?xml version='1.0' encoding="UTF-8"?>
  2. <!--
  3.  
  4.     OpenOffice.org - a multi-platform office productivity suite
  5.  
  6.     $RCSfile: sofftodocbookheadings.xsl,v $
  7.  
  8.     $Revision: 1.8 $
  9.  
  10.     last change: $Author: obo $ $Date: 2006/07/13 09:13:48 $
  11.  
  12.     The Contents of this file are made available subject to
  13.     the terms of GNU Lesser General Public License Version 2.1.
  14.  
  15.  
  16.       GNU Lesser General Public License Version 2.1
  17.       =============================================
  18.       Copyright 2005 by Sun Microsystems, Inc.
  19.       901 San Antonio Road, Palo Alto, CA 94303, USA
  20.  
  21.       This library is free software; you can redistribute it and/or
  22.       modify it under the terms of the GNU Lesser General Public
  23.       License version 2.1, as published by the Free Software Foundation.
  24.  
  25.       This library is distributed in the hope that it will be useful,
  26.       but WITHOUT ANY WARRANTY; without even the implied warranty of
  27.       MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  28.       Lesser General Public License for more details.
  29.  
  30.       You should have received a copy of the GNU Lesser General Public
  31.       License along with this library; if not, write to the Free Software
  32.       Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  33.       MA  02111-1307  USA
  34.  
  35. -->
  36. <xsl:stylesheet version="1.0" xmlns:style="http://openoffice.org/2000/style" xmlns:text="http://openoffice.org/2000/text" xmlns:office="http://openoffice.org/2000/office" xmlns:table="http://openoffice.org/2000/table" xmlns:draw="http://openoffice.org/2000/drawing" xmlns:fo="http://www.w3.org/1999/XSL/Format" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:meta="http://openoffice.org/2000/meta" xmlns:number="http://openoffice.org/2000/datastyle" xmlns:svg="http://www.w3.org/2000/svg" xmlns:chart="http://openoffice.org/2000/chart" xmlns:dr3d="http://openoffice.org/2000/dr3d" xmlns:math="http://www.w3.org/1998/Math/MathML" xmlns:form="http://openoffice.org/2000/form" xmlns:script="http://openoffice.org/2000/script" xmlns:config="http://openoffice.org/2001/config" office:class="text" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" exclude-result-prefixes="office meta  table number dc fo xlink chart math script xsl draw svg dr3d form config text style">
  37. <xsl:output method="xml" indent="yes" omit-xml-declaration="no"  />
  38. <xsl:output method="xml" version="1.0" encoding="UTF-8" doctype-public="-//OASIS//DTD DocBook XML V4.1.2//EN" doctype-system="http://www.oasis-open.org/docbook/xml/4.1.2/docbookx.dtd" />
  39.  
  40.  
  41.  
  42. <xsl:key name='headchildren' match="text:p |table:table | text:span | text:ordered-list | office:annotation | text:unordered-list | text:footnote | text:a | text:list-item | draw:plugin | draw:text-box | text:footnote-body | text:section"
  43.    use="generate-id((..|preceding-sibling::text:h[@text:level='1']|preceding-sibling::text:h[@text:level='2']|preceding-sibling::text:h[@text:level='3']|preceding-sibling::text:h[@text:level='4']|preceding-sibling::text:h[@text:level='5'])[last()])"/>
  44.  
  45. <xsl:key name="children" match="text:h[@text:level > '1' and @text:level < '6']"
  46.   use="generate-id(preceding-sibling::text:h[@text:level < current()/@text:level][1])"/>
  47.  
  48.  
  49. <xsl:template match="text:h[@text:level='1']">
  50. <xsl:choose>
  51.     <xsl:when test=".='Abstract'">
  52.         <abstract>
  53.             <xsl:apply-templates select="key('headchildren', generate-id())"/>
  54.                  <xsl:apply-templates select="key('children', generate-id())"/>
  55.         </abstract>
  56.     </xsl:when>
  57.     <xsl:otherwise>
  58.         <xsl:call-template name="make-section">
  59.             <xsl:with-param name="current" select="@text:level"/>
  60.                 <xsl:with-param name="prev" select="1"/>
  61.         </xsl:call-template>
  62.         <!--<sect1>
  63.                  <title>
  64.                        <xsl:apply-templates/>
  65.                  </title>
  66.                      <xsl:apply-templates select="key('headchildren', generate-id())"/>
  67.                  <xsl:apply-templates select="key('children', generate-id())"/>
  68.            </sect1>-->
  69.     </xsl:otherwise>
  70. </xsl:choose>
  71.  
  72. </xsl:template>
  73.  
  74. <xsl:template match="text:h[@text:level='2'] | text:h[@text:level='3']| text:h[@text:level='4'] | text:h[@text:level='5']">
  75. <xsl:variable name="level" select="@text:level"></xsl:variable>
  76. <xsl:call-template name="make-section">
  77.     <xsl:with-param name="current" select="$level"/>
  78.     <xsl:with-param name="prev" select="preceding-sibling::text:h[@text:level < $level][1]/@text:level "/>
  79. </xsl:call-template>
  80.  
  81. </xsl:template>
  82.  
  83. <xsl:template name="make-section">
  84.     <xsl:param name="current"/>
  85.     <xsl:param name="prev"/>
  86.     <xsl:choose>
  87.         <xsl:when test="$current > $prev+1">
  88.             <xsl:text disable-output-escaping="yes"><sect</xsl:text><xsl:value-of select="$prev +1"/><xsl:text disable-output-escaping="yes">></xsl:text>
  89.             <title>
  90.                 </title>
  91.             <xsl:call-template name="make-section">
  92.                 <xsl:with-param name="current" select="$current"/>
  93.                 <xsl:with-param name="prev" select="$prev +1"/>
  94.             </xsl:call-template>
  95.         <xsl:text disable-output-escaping="yes"></sect</xsl:text><xsl:value-of select="$prev +1 "/><xsl:text disable-output-escaping="yes">></xsl:text>
  96.         </xsl:when>
  97.  
  98.         <xsl:otherwise>
  99.             <xsl:text disable-output-escaping="yes"><sect</xsl:text><xsl:value-of select="$current"/><xsl:text disable-output-escaping="yes">></xsl:text>
  100.                     <title>
  101.                                <xsl:apply-templates/>
  102.                         </title>
  103.                  <xsl:apply-templates select="key('headchildren', generate-id())"/>
  104.                     <xsl:apply-templates select="key('children', generate-id())"/>
  105.             <xsl:text disable-output-escaping="yes"></sect</xsl:text><xsl:value-of select="$current"/><xsl:text disable-output-escaping="yes">></xsl:text>
  106.         </xsl:otherwise>
  107.     </xsl:choose>
  108. </xsl:template>
  109.  
  110.  
  111. <xsl:template match="text:p">
  112.         <xsl:element name="para">
  113.               <xsl:apply-templates/>
  114.         </xsl:element>
  115. </xsl:template>
  116.  
  117.  
  118.  
  119. <xsl:template match="/office:document">
  120.     <xsl:element name="article">
  121.         <xsl:attribute name="lang"><xsl:value-of select="/office:document/office:meta/dc:language"/>
  122.         </xsl:attribute>
  123.         <xsl:apply-templates select="office:body"/>
  124.     </xsl:element>
  125. </xsl:template>
  126.  
  127. <xsl:template match="office:meta">
  128.     <!--<xsl:apply-templates/>-->
  129. </xsl:template>
  130.  
  131. <xsl:template match="text:ordered-list">
  132.     <xsl:element name="orderedlist">
  133.         <xsl:apply-templates/>
  134.     </xsl:element>
  135. </xsl:template>
  136.  
  137.  
  138.  
  139. <xsl:template match="meta:editing-cycles">
  140. </xsl:template>
  141.  
  142. <xsl:template match="meta:user-defined">
  143. </xsl:template>
  144.  
  145. <xsl:template match="meta:editing-duration">
  146. </xsl:template>
  147.  
  148. <xsl:template match="dc:language">
  149. </xsl:template>
  150.  
  151. <xsl:template match="dc:date">
  152.     <!--<pubdate>
  153.         <xsl:value-of select="substring-before(.,'T')"/>
  154.     </pubdate>-->
  155. </xsl:template>
  156.  
  157. <xsl:template match="meta:creation-date">
  158. </xsl:template>
  159.  
  160. <xsl:template match="office:body">
  161. <xsl:apply-templates select="key('headchildren', generate-id())"/>
  162.    <xsl:apply-templates select="text:h[@text:level='1']"/>
  163.     <!--<xsl:apply-templates/>-->
  164. </xsl:template>
  165.  
  166. <xsl:template match="office:styles">
  167.     <xsl:apply-templates/>
  168. </xsl:template>
  169.  
  170. <xsl:template match="office:script">
  171. </xsl:template>
  172.  
  173.  
  174. <xsl:template match="office:settings">
  175. </xsl:template>
  176.  
  177. <xsl:template match="office:font-decls">
  178. </xsl:template>
  179.  
  180. <xsl:template match="text:section">
  181. <xsl:choose>
  182.     <xsl:when test="@text:name='ArticleInfo'">
  183.         <articleinfo>
  184.             <title><xsl:value-of select="text:p[@text:style-name='Document Title']"/></title>
  185.             <subtitle><xsl:value-of select="text:p[@text:style-name='Document SubTitle']"/></subtitle>
  186.             <edition><xsl:value-of select="text:p/text:variable-set[@text:name='articleinfo.edition']"/></edition>
  187.             <xsl:for-each select="text:p/text:variable-set[substring-after(@text:name,'articleinfo.releaseinfo')]">
  188.                 <releaseinfo>
  189.                     <xsl:value-of select="."/>
  190.                 </releaseinfo>
  191.             </xsl:for-each>
  192.             <xsl:call-template name="ArticleInfo"><xsl:with-param name="level" select="0"/></xsl:call-template>
  193.  
  194.         </articleinfo>
  195.     </xsl:when>
  196.     <xsl:when test="@text:name='Abstract'">
  197.         <abstract>
  198.             <xsl:apply-templates/>
  199.         </abstract>
  200.     </xsl:when>
  201.     <xsl:when test="@text:name='Appendix'">
  202.         <appendix>
  203.             <xsl:apply-templates/>
  204.         </appendix>
  205.     </xsl:when>
  206.     <xsl:otherwise>
  207.         <xsl:variable name="sectvar"><xsl:text>sect</xsl:text><xsl:value-of select="count(ancestor::text:section)+1"/></xsl:variable>
  208.         <xsl:variable name="idvar"><xsl:text> id="</xsl:text><xsl:value-of select="@text:name"/><xsl:text>"</xsl:text></xsl:variable>
  209.         <xsl:text disable-output-escaping="yes"><</xsl:text><xsl:value-of select="$sectvar"/><xsl:value-of select="$idvar"/><xsl:text  disable-output-escaping="yes">></xsl:text>
  210.             <xsl:apply-templates/>
  211.         <xsl:text disable-output-escaping="yes"></</xsl:text><xsl:value-of select="$sectvar"/><xsl:text  disable-output-escaping="yes">></xsl:text>
  212.     </xsl:otherwise>
  213.  
  214.  
  215. </xsl:choose>
  216. </xsl:template>
  217.  
  218. <xsl:template name="ArticleInfo">
  219.     <xsl:param name="level"/>
  220.     <xsl:variable name="author"><xsl:value-of select="concat('articleinfo.author_','', $level)"/></xsl:variable>
  221.     <xsl:if test="text:p/text:variable-set[contains(@text:name, $author )]">
  222.         <xsl:call-template name="Author"><xsl:with-param name="AuthorLevel" select="0"/></xsl:call-template>
  223.         <xsl:call-template name="Copyright"><xsl:with-param name="CopyrightLevel" select="0"/></xsl:call-template>
  224.     </xsl:if>
  225. </xsl:template>
  226.  
  227. <xsl:template name="Copyright">
  228.     <xsl:param name="CopyrightLevel"/>
  229.  
  230.     <xsl:variable name="Copyright"><xsl:value-of select="concat('articleinfo.copyright_','', $CopyrightLevel)"/></xsl:variable>
  231.  
  232.     <xsl:if test="text:p/text:variable-set[contains(@text:name,$Copyright)]">
  233.         <copyright>
  234.             <xsl:call-template name="Year">
  235.                 <xsl:with-param name="CopyrightLevel" select="$CopyrightLevel"/>
  236.                 <xsl:with-param name="YearlLevel" select="0"/>
  237.             </xsl:call-template>
  238.             <xsl:call-template name="Holder">
  239.                 <xsl:with-param name="CopyrightLevel" select="$CopyrightLevel"/>
  240.                 <xsl:with-param name="HolderlLevel" select="0"/>
  241.  
  242.             </xsl:call-template>
  243.         </copyright>
  244.     </xsl:if>
  245. </xsl:template>
  246.  
  247.  
  248. <xsl:template name="Year">
  249.     <xsl:param name="CopyrightLevel"/>
  250.     <xsl:param name="YearLevel"/>
  251.     <xsl:variable name="Copyright"><xsl:value-of select="concat('articleinfo.copyright_','', $CopyrightLevel)"/></xsl:variable>
  252. <xsl:variable name="Year"><xsl:value-of select="concat($Copyright,'',concat('.year_','',$YearLevel))"/></xsl:variable>
  253.  
  254.     <xsl:if test="text:p/text:variable-set[@text:name=$Year]">
  255.         <orgname>
  256.             <xsl:value-of select="text:p/text:variable-set[@text:name=$Year]"/>
  257.         </orgname>
  258.     </xsl:if>
  259. </xsl:template>
  260.  
  261.  
  262. <xsl:template name="Holder">
  263.     <xsl:param name="CopyrightLevel"/>
  264.     <xsl:param name="HolderLevel"/>
  265.     <xsl:variable name="Copyright"><xsl:value-of select="concat('articleinfo.copyright_','', $CopyrightLevel)"/></xsl:variable>
  266. <xsl:variable name="Holder"><xsl:value-of select="concat($Copyright,'',concat('.holder_','',$HolderLevel))"/></xsl:variable>
  267.  
  268.     <xsl:if test="text:p/text:variable-set[@text:name=$Holder]">
  269.         <orgname>
  270.             <xsl:value-of select="text:p/text:variable-set[@text:name=$Holder]"/>
  271.         </orgname>
  272.     </xsl:if>
  273. </xsl:template>
  274.  
  275.  
  276.  
  277. <xsl:template name="Author">
  278.     <xsl:param name="AuthorLevel"/>
  279.     <xsl:variable name="Author"><xsl:value-of select="concat('articleinfo.author_','', $AuthorLevel)"/></xsl:variable>
  280.     <xsl:if test="text:p/text:variable-set[contains(@text:name, $Author )]">
  281.         <author>
  282.             <xsl:call-template name="Surname"><xsl:with-param name="AuthorLevel" select="$AuthorLevel"/><xsl:with-param name="SurnameLevel" select="0"/></xsl:call-template>
  283.             <xsl:call-template name="Firstname"><xsl:with-param name="AuthorLevel" select="$AuthorLevel"/><xsl:with-param name="FirstnameLevel" select="0"/></xsl:call-template>
  284.             <xsl:call-template name="Affiliation"><xsl:with-param name="AuthorLevel" select="$AuthorLevel"/><xsl:with-param name="AffilLevel" select="0"/></xsl:call-template>
  285.         </author>
  286.         <xsl:call-template name="Author"><xsl:with-param name="AuthorLevel" select="$AuthorLevel+1"/></xsl:call-template>
  287.     </xsl:if>
  288. </xsl:template>
  289.  
  290.  
  291. <xsl:template name="Surname">
  292.     <xsl:param name="AuthorLevel"/>
  293.     <xsl:param name="SurnameLevel"/>
  294.     <xsl:variable name="Author"><xsl:value-of select="concat('articleinfo.author_','', $AuthorLevel)"/></xsl:variable>
  295.     <xsl:variable name="Surname"><xsl:value-of select="concat($Author,'',concat('.surname_','',$SurnameLevel))"/></xsl:variable>
  296.     <xsl:if test="text:p/text:variable-set[@text:name=$Surname]">
  297.         <surname>
  298.             <xsl:value-of select="text:p/text:variable-set[@text:name=$Surname]"/>
  299.         </surname>
  300.         <xsl:call-template name="Surname"><xsl:with-param name="AuthorLevel" select="$AuthorLevel"/>
  301.         <xsl:with-param name="SurnameLevel" select="SurnameLevel+1"/>
  302.         </xsl:call-template>
  303.  
  304.     </xsl:if>
  305. </xsl:template>
  306.  
  307.  
  308.  
  309.  
  310. <xsl:template name="Firstname">
  311.     <xsl:param name="AuthorLevel"/>
  312.     <xsl:param name="FirstnameLevel"/>
  313.     <xsl:variable name="Author"><xsl:value-of select="concat('articleinfo.author_','', $AuthorLevel)"/></xsl:variable>
  314.     <xsl:variable name="Firstname"><xsl:value-of select="concat($Author,'',concat('.firstname_','',$FirstnameLevel))"/></xsl:variable>
  315.     <xsl:if test="text:p/text:variable-set[@text:name=$Firstname]">
  316.         <firstname>
  317.             <xsl:value-of select="text:p/text:variable-set[@text:name=$Firstname]"/>
  318.         </firstname>
  319.         <xsl:call-template name="Surname">
  320.             <xsl:with-param name="AuthorLevel" select="$AuthorLevel"/>
  321.             <xsl:with-param name="FirstnameLevel" select="FirstnameLevel+1"/>
  322.         </xsl:call-template>
  323.     </xsl:if>
  324. </xsl:template>
  325.  
  326.  
  327.  
  328. <xsl:template name="Affiliation">
  329.     <xsl:param name="AuthorLevel"/>
  330.     <xsl:param name="AffilLevel"/>
  331.     <xsl:variable name="Author"><xsl:value-of select="concat('articleinfo.author_','', $AuthorLevel)"/></xsl:variable>
  332.     <xsl:variable name="Affil"><xsl:value-of select="concat($Author,'',concat('.affiliation_','',$AffilLevel))"/></xsl:variable>
  333.     <xsl:if test="text:p/text:variable-set[contains(@text:name,$Affil)]">
  334.         <affiliation>
  335.             <xsl:call-template name="Orgname">
  336.                 <xsl:with-param name="AuthorLevel" select="$AuthorLevel"/>
  337.                 <xsl:with-param name="AffilLevel" select="$AffilLevel"/><xsl:with-param name="OrgLevel" select="0"/>
  338.             </xsl:call-template>
  339.             <xsl:call-template name="Address">
  340.                 <xsl:with-param name="AuthorLevel" select="$AuthorLevel"/>
  341.                 <xsl:with-param name="AffilLevel" select="$AffilLevel"/><xsl:with-param name="AddressLevel" select="0"/>
  342.  
  343.             </xsl:call-template>
  344.         </affiliation>
  345.     </xsl:if>
  346. </xsl:template>
  347.  
  348. <xsl:template name="Orgname">
  349.     <xsl:param name="AuthorLevel"/>
  350.     <xsl:param name="AffilLevel"/>
  351.     <xsl:param name="OrgLevel"/>
  352.  
  353.     <xsl:variable name="Author"><xsl:value-of select="concat('articleinfo.author_','', $AuthorLevel)"/></xsl:variable>
  354. <xsl:variable name="Affil"><xsl:value-of select="concat($Author,'',concat('.affiliation_','',$AffilLevel))"/></xsl:variable>
  355.     <xsl:variable name="Org"><xsl:value-of select="concat($Affil,'',concat('.orgname_','',$OrgLevel))"/></xsl:variable>
  356.  
  357.     <xsl:if test="text:p/text:variable-set[@text:name=$Org]">
  358.         <orgname>
  359.             <xsl:value-of select="text:p/text:variable-set[@text:name=$Org]"/>
  360.         </orgname>
  361.     </xsl:if>
  362. </xsl:template>
  363.  
  364. <xsl:template name="Address">
  365.     <xsl:param name="AuthorLevel"/>
  366.     <xsl:param name="AffilLevel"/>
  367.     <xsl:param name="AddressLevel"/>
  368.  
  369.     <xsl:variable name="Author"><xsl:value-of select="concat('articleinfo.author_','', $AuthorLevel)"/></xsl:variable>
  370. <xsl:variable name="Affil"><xsl:value-of select="concat($Author,'',concat('.affiliation_','',$AffilLevel))"/></xsl:variable>
  371.     <xsl:variable name="Address"><xsl:value-of select="concat($Affil,'',concat('.address_','',$AddressLevel))"/></xsl:variable>
  372.  
  373.     <xsl:if test="text:p/text:variable-set[@text:name=$Address]">
  374.         <address>
  375.             <xsl:value-of select="text:p/text:variable-set[@text:name=$Address]"/>
  376.         </address>
  377.     </xsl:if>
  378. </xsl:template>
  379.  
  380.  
  381.  
  382.  
  383. <xsl:template match="text:p[@text:style-name='Document Title']">
  384. </xsl:template>
  385.  
  386. <xsl:template match="text:p[@text:style-name='Document SubTitle']">
  387. </xsl:template>
  388.  
  389.  
  390. <xsl:template match="text:p[@text:style-name='Section Title']">
  391.     <xsl:element name="title">
  392.         <xsl:apply-templates/>
  393.     </xsl:element>
  394. </xsl:template>
  395.  
  396. <xsl:template match="text:p[@text:style-name='Appendix Title']">
  397.     <xsl:element name="title">
  398.         <xsl:apply-templates/>
  399.     </xsl:element>
  400. </xsl:template>
  401.  
  402.  
  403. <!--<xsl:template match="text:p[@text:style-name='VarList Item']">
  404.     <xsl:if test="not(preceding-sibling::text:p[@text:style-name='VarList Item'])">
  405.         <xsl:text disable-output-escaping="yes"><listitem></xsl:text>
  406.     </xsl:if>
  407.         <para>
  408.             <xsl:apply-templates/>
  409.         </para>
  410.     <xsl:if test="not(following-sibling::text:p[@text:style-name='VarList Item'])">
  411.         <xsl:text disable-output-escaping="yes"></listitem></xsl:text>
  412.     </xsl:if>
  413. </xsl:template>-->
  414.  
  415. <xsl:template match="text:p[@text:style-name='VarList Term']">
  416.     <xsl:element name="term">
  417.             <xsl:apply-templates/>
  418.     </xsl:element>
  419. </xsl:template>
  420.  
  421. <xsl:template match="text:p[@text:style-name='VarList Item']">
  422.     <xsl:element name="listitem">
  423.         <xsl:element name="para">
  424.             <xsl:apply-templates/>
  425.         </xsl:element>
  426.     </xsl:element>
  427. </xsl:template>
  428.  
  429. <xsl:template match="text:p[@text:style-name='Section1 Title']">
  430.     <xsl:element name="title">
  431.         <xsl:apply-templates/>
  432.     </xsl:element>
  433. </xsl:template>
  434.  
  435.  
  436. <xsl:template match="text:p[@text:style-name='Section2 Title']">
  437.     <xsl:element name="title">
  438.         <xsl:apply-templates/>
  439.     </xsl:element >
  440. </xsl:template>
  441.  
  442.  
  443. <xsl:template match="text:p[@text:style-name='Section3 Title']">
  444.     <xsl:element name="title">
  445.         <xsl:apply-templates/>
  446.     </xsl:element>
  447. </xsl:template>
  448.  
  449. <xsl:template match="text:footnote-citation">
  450. </xsl:template>
  451.  
  452. <xsl:template match="text:p[@text:style-name='Mediaobject']">
  453.     <mediaobject>
  454.         <xsl:apply-templates/>
  455.     </mediaobject>
  456. </xsl:template>
  457.  
  458. <xsl:template match="office:annotation/text:p">
  459.     <note>
  460.     <remark>
  461.         <xsl:apply-templates/>
  462.     </remark>
  463.     </note>
  464. </xsl:template>
  465.  
  466. <!--<xsl:template match="meta:initial-creator">
  467.     <author>
  468.     <xsl:apply-templates />
  469.         </author>
  470. </xsl:template>-->
  471.  
  472. <xsl:template match="table:table">
  473.     <xsl:choose>
  474.         <xsl:when test="following-sibling::text:p[@text:style-name='Table']">
  475.             <table frame="all">
  476.                  <xsl:attribute name="id">
  477.                     <xsl:value-of select="@table:name"/>
  478.                 </xsl:attribute>
  479.                 <title>
  480.                     <xsl:value-of select="following-sibling::text:p[@text:style-name='Table']"/>
  481.                 </title>
  482.                 <xsl:call-template name="generictable"/>
  483.             </table>
  484.         </xsl:when>
  485.         <xsl:otherwise>
  486.             <informaltable frame="all">
  487.                 <xsl:call-template name="generictable"/>
  488.             </informaltable>
  489.         </xsl:otherwise>
  490.     </xsl:choose>
  491. </xsl:template>
  492.  
  493.  
  494. <xsl:template name="generictable">
  495.             <xsl:variable name="cells" select="count(descendant::table:table-cell)" ></xsl:variable>
  496.             <xsl:variable name="rows"><xsl:value-of select="count(descendant::table:table-row) "/></xsl:variable>
  497.             <xsl:variable name="cols"><xsl:value-of select="$cells div $rows"/></xsl:variable>
  498.             <xsl:variable name="numcols">
  499.             <xsl:choose>
  500.                     <xsl:when test="child::table:table-column/@table:number-columns-repeated">
  501.                             <xsl:value-of select="number(table:table-column/@table:number-columns-repeated+1)"/>
  502.                     </xsl:when>
  503.                     <xsl:otherwise >
  504.                             <xsl:value-of select="$cols"/>
  505.                     </xsl:otherwise>
  506.             </xsl:choose>
  507.         </xsl:variable>
  508.         <xsl:element name="tgroup">
  509.             <xsl:attribute name="cols">
  510.                         <xsl:value-of select="$numcols"/>
  511.             </xsl:attribute>
  512.             <xsl:call-template name="colspec"><xsl:with-param name="left" select="1" /></xsl:call-template>
  513.                 <xsl:apply-templates/>
  514.         </xsl:element>
  515. </xsl:template>
  516.  
  517.  
  518.  
  519. <xsl:template name="colspec">
  520.     <xsl:param name="left"/>
  521.     <xsl:if test="number($left < ( table:table-column/@table:number-columns-repeated +2)  )">
  522.             <xsl:element name="colspec">
  523.                 <xsl:attribute name="colnum"><xsl:value-of select="$left"/></xsl:attribute>
  524.                 <xsl:attribute name="colname">c<xsl:value-of select="$left"/></xsl:attribute>
  525.             </xsl:element>
  526.             <xsl:call-template name="colspec"><xsl:with-param name="left" select="$left+1" /></xsl:call-template>
  527.     </xsl:if>
  528. </xsl:template>
  529.  
  530.  
  531.  
  532. <xsl:template match="table:table-column">
  533.         <xsl:apply-templates/>
  534. </xsl:template>
  535.  
  536. <xsl:template match="table:table-header-rows">
  537.     <thead>
  538.         <xsl:apply-templates/>
  539.     </thead>
  540. </xsl:template>
  541.  
  542. <xsl:template match="table:table-header-rows/table:table-row">
  543.     <row>
  544.         <xsl:apply-templates />
  545.     </row>
  546. </xsl:template>
  547.  
  548. <xsl:template match="table:table/table:table-row">
  549.     <xsl:if test="not(preceding-sibling::table:table-row)">
  550.         <xsl:text disable-output-escaping="yes"><tbody></xsl:text>
  551.     </xsl:if>
  552.     <row>
  553.         <xsl:apply-templates />
  554.     </row>
  555.         <xsl:if test="not(following-sibling::table:table-row)">
  556.         <xsl:text disable-output-escaping="yes"></tbody></xsl:text>
  557.     </xsl:if>
  558. </xsl:template>
  559.  
  560. <xsl:template match="table:table-cell">
  561.  <xsl:element name="entry">
  562.          <xsl:if test="@table:number-columns-spanned >'1'">
  563.             <xsl:attribute name="namest"><xsl:value-of select="concat('c',count(preceding-sibling::table:table-cell[not(@table:number-columns-spanned)]) +sum(preceding-sibling::table:table-cell/@table:number-columns-spanned)+1)"/></xsl:attribute>
  564.             <xsl:attribute name="nameend"><xsl:value-of select="concat('c',count(preceding-sibling::table:table-cell[not(@table:number-columns-spanned)]) +sum(preceding-sibling::table:table-cell/@table:number-columns-spanned)+ @table:number-columns-spanned)"/></xsl:attribute>
  565.         </xsl:if>
  566.         <xsl:apply-templates />
  567.     </xsl:element>
  568. </xsl:template>
  569.  
  570. <xsl:template match="text:p">
  571. <xsl:choose>
  572.     <xsl:when test="@text:style-name='Table'">
  573.     </xsl:when>
  574.     <xsl:otherwise>
  575.         <para>
  576.             <xsl:apply-templates/>
  577.         </para>
  578.     </xsl:otherwise>
  579. </xsl:choose>
  580. </xsl:template>
  581.  
  582. <xsl:template match="text:unordered-list">
  583. <xsl:choose>
  584.     <xsl:when  test="@text:style-name='Var List'">
  585.         <variablelist>
  586.             <xsl:apply-templates/>
  587.         </variablelist>
  588.     </xsl:when>
  589.     <xsl:when  test="@text:style-name='UnOrdered List'">
  590.         <itemizedlist>
  591.             <xsl:apply-templates/>
  592.         </itemizedlist>
  593.     </xsl:when>
  594.     <xsl:otherwise>
  595.     <itemizedlist>
  596.         <xsl:apply-templates/>
  597.     </itemizedlist>
  598.     </xsl:otherwise>
  599. </xsl:choose>
  600. </xsl:template>
  601.  
  602. <xsl:template match="text:list-item">
  603. <!--    <xsl:if test="parent::text:unordered-list/@text:style-name='Var List'">
  604.  
  605.     </xsl:if>
  606.     <xsl:if test="not(parent::text:unordered-list/@text:style-name='Var List')">
  607.         <listitem>
  608.             <xsl:apply-templates/>
  609.         </listitem>
  610.     </xsl:if>-->
  611.     <xsl:choose>
  612.         <xsl:when test="parent::text:unordered-list/@text:style-name='Var List' ">
  613.             <xsl:if test="child::text:p[@text:style-name='VarList Term']">
  614.             <xsl:element name="varlistentry">
  615.                     <xsl:apply-templates select="child::text:p[@text:style-name='VarList Term']"/>
  616.                         <xsl:if test="following-sibling::text:list-item[1]/text:p[@text:style-name='VarList Item']">
  617.                             <xsl:apply-templates select="following-sibling::text:list-item[1]/text:p"/>
  618.                         </xsl:if>
  619.                   </xsl:element>
  620.             </xsl:if>
  621.         </xsl:when>
  622.         <xsl:otherwise>
  623.             <xsl:element name="listitem">
  624.                 <xsl:apply-templates/>
  625.             </xsl:element>
  626.         </xsl:otherwise>
  627.     </xsl:choose>
  628. </xsl:template>
  629.  
  630.  
  631.  
  632.  
  633.  
  634. <xsl:template match="dc:title">
  635. </xsl:template>
  636.  
  637. <xsl:template match="dc:description">
  638.     <abstract><para>
  639.         <xsl:apply-templates/>
  640.         </para>
  641.     </abstract>
  642. </xsl:template>
  643.  
  644. <xsl:template match="dc:subject">
  645. </xsl:template>
  646.  
  647.  
  648. <xsl:template match="meta:generator">
  649. </xsl:template>
  650.  
  651. <xsl:template match="draw:plugin">
  652. <xsl:element name="audioobject">
  653.     <xsl:attribute name="fileref">
  654.         <xsl:value-of select="@xlink:href"/>
  655.     </xsl:attribute>
  656.     <xsl:attribute name="width">
  657.     </xsl:attribute>
  658. </xsl:element>
  659. </xsl:template>
  660.  
  661. <xsl:template match="text:footnote">
  662.     <footnote>
  663.         <xsl:apply-templates/>
  664.     </footnote>
  665. </xsl:template>
  666.  
  667. <xsl:template match="text:footnote-body">
  668.         <xsl:apply-templates/>
  669. </xsl:template>
  670.  
  671.  
  672. <xsl:template match="draw:text-box">
  673. </xsl:template>
  674.  
  675.  
  676.  
  677. <xsl:template match="draw:image">
  678. <xsl:choose>
  679.     <xsl:when test="parent::text:p[@text:style-name='Mediaobject']">
  680.         <xsl:element name="imageobject">
  681.             <xsl:element name="imagedata">
  682.             <xsl:attribute name="fileref">
  683.                 <xsl:value-of select="@xlink:href"/>
  684.             </xsl:attribute>
  685.             </xsl:element>
  686.             <xsl:element name="caption">
  687.                 <xsl:value-of select="."/>
  688.             </xsl:element>
  689.         </xsl:element>
  690.     </xsl:when>
  691.     <xsl:otherwise>
  692.         <xsl:element name="inlinegraphic">
  693.             <xsl:attribute name="fileref">
  694.                 <xsl:value-of select="@xlink:href"/>
  695.             </xsl:attribute>
  696.             <xsl:attribute name="width"></xsl:attribute>
  697.         </xsl:element>
  698.     </xsl:otherwise>
  699. </xsl:choose>
  700. </xsl:template>
  701.  
  702.  
  703.  
  704.  
  705.  
  706. <xsl:template match="text:span">
  707. <xsl:choose>
  708. <xsl:when test="./@text:style-name='GuiMenu'">
  709.         <xsl:element name="guimenu">
  710.             <xsl:value-of select="."/>
  711.         </xsl:element>
  712.     </xsl:when>
  713.     <xsl:when test="./@text:style-name='GuiSubMenu'">
  714.         <xsl:element name="guisubmenu">
  715.             <xsl:value-of select="."/>
  716.         </xsl:element>
  717.     </xsl:when>
  718.         <xsl:when test="@text:style-name='GuiMenuItem'">
  719.         <xsl:element name="guimenuitem">
  720.             <xsl:value-of select="."/>
  721.         </xsl:element>
  722.     </xsl:when>
  723.     <xsl:when test="@text:style-name='GuiButton'">
  724.         <xsl:element name="guibutton">
  725.             <xsl:value-of select="."/>
  726.         </xsl:element>
  727.     </xsl:when>
  728.         <xsl:when test="@text:style-name='GuiButton'">
  729.         <xsl:element name="guibutton">
  730.             <xsl:value-of select="."/>
  731.         </xsl:element>
  732.     </xsl:when>
  733.     <xsl:when test="@text:style-name='GuiLabel'">
  734.         <xsl:element name="guilabel">
  735.             <xsl:value-of select="."/>
  736.         </xsl:element>
  737.     </xsl:when>
  738.     <xsl:when test="@text:style-name='Emphasis'">
  739.         <xsl:element name="emphasis">
  740.             <xsl:value-of select="."/>
  741.         </xsl:element>
  742.     </xsl:when>
  743.     <xsl:when test="@text:style-name='FileName'">
  744.         <xsl:element name="filename">
  745.             <xsl:value-of select="."/>
  746.         </xsl:element>
  747.     </xsl:when>
  748.     <xsl:when test="@text:style-name='Application'">
  749.         <xsl:element name="application">
  750.             <xsl:value-of select="."/>
  751.         </xsl:element>
  752.     </xsl:when>
  753.     <xsl:when test="@text:style-name='Command'">
  754.         <command>
  755.             <xsl:apply-templates/>
  756.         </command>
  757.     </xsl:when>
  758.     <xsl:when test="@text:style-name='SubScript'">
  759.         <subscript>
  760.             <xsl:apply-templates/>
  761.         </subscript>
  762.     </xsl:when>
  763.     <xsl:when test="@text:style-name='SuperScript'">
  764.         <superscript>
  765.             <xsl:apply-templates/>
  766.         </superscript>
  767.     </xsl:when>
  768.     <xsl:when test="@text:style-name='SystemItem'">
  769.         <systemitem>
  770.             <xsl:apply-templates/>
  771.         </systemitem>
  772.     </xsl:when>
  773.     <xsl:when test="@text:style-name='ComputerOutput'">
  774.         <computeroutput>
  775.             <xsl:apply-templates/>
  776.         </computeroutput>
  777.     </xsl:when>
  778.     <xsl:when test="@text:style-name='Highlight'">
  779.         <highlight>
  780.             <xsl:apply-templates/>
  781.         </highlight>
  782.     </xsl:when>
  783.         <xsl:when test="@text:style-name='KeyCap'">
  784.         <keycap>
  785.             <xsl:apply-templates/>
  786.         </keycap>
  787.     </xsl:when>
  788.     <xsl:when test="@text:style-name='KeySym'">
  789.         <xsl:element name="keysym">
  790.             <xsl:apply-templates/>
  791.         </xsl:element>
  792.     </xsl:when>
  793.     <xsl:when test="@text:style-name='KeyCombo'">
  794.         <keycombo>
  795.             <xsl:apply-templates/>
  796.         </keycombo>
  797.     </xsl:when>
  798.     <xsl:otherwise>
  799.         <xsl:apply-templates/>
  800.     </xsl:otherwise>
  801. </xsl:choose>
  802.  
  803. </xsl:template>
  804.  
  805.  
  806. <xsl:template match="text:a">
  807.     <xsl:choose>
  808.         <xsl:when test="contains(@xlink:href,'://')">
  809.             <xsl:element name="ulink">
  810.                 <xsl:attribute name="url">
  811.                     <xsl:value-of select="@xlink:href"/>
  812.                 </xsl:attribute>
  813.                 <xsl:apply-templates/>
  814.             </xsl:element>
  815.         </xsl:when>
  816.         <xsl:when test="contains(@xlink:href,'mailto:')">
  817.             <xsl:element name="ulink">
  818.                 <xsl:attribute name ="url">
  819.                     <xsl:value-of select="@xlink:href"/>
  820.                 </xsl:attribute>
  821.                 <xsl:apply-templates/>
  822.             </xsl:element>
  823.         </xsl:when>
  824.         <xsl:when test="not(contains(@xlink:href,'#'))">
  825.             <xsl:element name="olink">
  826.                 <xsl:attribute name="targetdocent">
  827.                     <xsl:value-of select="@xlink:href"/>
  828.                 </xsl:attribute>
  829.                 <xsl:apply-templates/>
  830.             </xsl:element>
  831.         </xsl:when>
  832.         <xsl:otherwise>
  833.         <xsl:variable name="linkvar" select="substring-after(@xlink:href,'#')"/>
  834.             <xsl:element name="link">
  835.                 <xsl:attribute name="linkend">
  836.                     <xsl:value-of select="substring-before($linkvar,'%')"/>
  837.                 </xsl:attribute>
  838.                 <xsl:apply-templates/>
  839.             </xsl:element>
  840.         </xsl:otherwise>
  841.     </xsl:choose>
  842. </xsl:template>
  843.  
  844. <!--
  845.     Change Made By Kevin Fowlks (fowlks@msu.edu) July 2nd, 2003
  846.     This allows users to create example code in DocBook.
  847.  
  848.     Note: This type of grouping could also be implemented for
  849.     <notes>,<literallayout>, <blockquote> or any other tag that requires text to be treated as blocked.
  850. -->
  851. <xsl:template match="text:p[@text:style-name='Example']">
  852.     <xsl:if test="not(preceding-sibling::*[1][self::text:p[@text:style-name='Example']])">
  853.         <xsl:element name="example">
  854.             <xsl:element name="title"></xsl:element>
  855.             <xsl:element name="programlisting">
  856.                 <xsl:value-of select="." />
  857.                 <xsl:text disable-output-escaping="no"> </xsl:text>
  858.                 <xsl:apply-templates mode="in-list"
  859.                         select="following-sibling::*[1][self::text:p[@text:style-name='Example']]" />
  860.             </xsl:element>
  861.         </xsl:element>
  862.     </xsl:if>
  863. </xsl:template>
  864.  
  865. <xsl:template match="text:p[@text:style-name='Example']" mode="in-list">
  866.     <xsl:value-of select="." />
  867.     <xsl:text disable-output-escaping="no"> </xsl:text>
  868.     <xsl:apply-templates mode="in-list" select="following-sibling::*[1][self::text:p[@text:style-name='Example']]"/>
  869. </xsl:template>
  870. </xsl:stylesheet>
  871.